package com.my.mapper;

import com.my.entity.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {

/*    @Results({
            @Result(column = "createTime", property = "create_time"),
            @Result(column = "updateTime", property = "update_time")
    })*/
    // !可能的错误 因为XML也绑定了
    @Select("select * from dept")
    public List<Dept> list();

    @Delete("delete from dept where id = #{id}")
    Integer deptDelete(Integer id);

    @Insert("insert into dept (name, create_time, update_time) VALUES (#{name}, #{createTime},#{updateTime})")
    void addDept(Dept dept);

    @Select("select * from dept where id = #{id}")
    Dept getDeptById(Integer id);


    // @Update("update dept set update_time = #{updateTime}, name = #{name} where id = #{id}")
    // 动态SQL需要借助XML

    void updateDept(Dept dept);
}